<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('公司列表')"/>
    <th:block th:include="include :: layout-latest-css"/>
    <th:block th:include="include :: ztree-css"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="role-form">
                <div class="select-list">
                    <ul>
                        <li>
                            区域公司：<input type="text" name="title"/>
                        </li>
                        <li>
                            项目名称：<input type="text" name="compID"/>
                        </li>
                        <li>
                            区域公司：<select name="status">
                            <option value="">全部</option>
                            <option value="0">皖东区域公司</option>
                            <option value="1">江苏区域公司</option>
                            <option value="2">合肥区域公司</option>
                            <option value="3">南方区域公司</option>
                            <option value="4">徐州区域公司</option>
                            <option value="5">中原区域公司</option>
                            <option value="6">项目管理公司</option>
                            <option value="7">市政工程公司</option>
                            <option value="8">淮海区域公司</option>
                        </select>
                        </li>
                        <li>
                            年：<select name="status">
                            <option value="">全部</option>

                        </select>
                        </li>
                        <li>
                            月：<select name="status">
                            <option value="">全部</option>
                        </select>
                        </li>
                        <li>
                            项目名称：<select name="status">
                            <option value="">全部</option>
                        </select>
                        </li>
                        <li>
                            费用类型：<select name="status">
                            <option value="">全部</option>
                        </select>
                        </li>

                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-info" onclick="$.table.importExcel()">
                <i class="fa fa-upload"></i> 导入
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:role:export">
                <i class="fa fa-download"></i> 导出
            </a>
            <button class="btn btn-info" onclick="detail()"><i class="fa fa-search"></i> 查看</button>

        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="emp-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: layout-latest-js"/>
<th:block th:include="include :: ztree-js"/>
<th:block th:include="include :: select2-js"/>
<th:block th:include="include :: datetimepicker-js"/>


<script th:inline="javascript">
    var prefix = ctx + "jpbi/comp";

    $(function () {
        queryUserList();
    });

    function queryUserList() {
        var options = {
            id: "emp-table",
            code: "compID",
            uniqueId: "compID",
            createUrl: prefix + "/add",
            removeUrl: prefix + "/remove",
            detailUrl: prefix + "/detail",
            url: prefix + "/getCompList",
            exportUrl: prefix + "/export",
            modalName: "人员信息",

            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '区域公司'
                },
                {
                    field: 'year',
                    title: '年',
                },
                {
                    field: 'month',
                    title: '月',
                },
                {
                    field: 'jspmName',
                    title: '项目名称',
                },
                {
                    field: 'exepenseType',
                    title: '费用类型',
                },
                {
                    field: 'exepense',
                    title: '费用金额',
                },
                {
                    field: 'remarks',
                    title: '备注',
                }]
        };
        $.table.init(options);
    }

    function add() {
        $.operate.add();
    }

    function edit() {
        var row = $("#emp-table").bootstrapTable('getSelections');
        var num = 0;
        var allEid = "";
        if (row.length == 0) {
            $.modal.alertWarning("请选择需要修改的人员");
            return;
        }
        for (var i = 0; i < row.length; i++) {
            $.operate.edit_currency(row[i].compID, row[i].title, "/jpbi/comp/editComp","xiao");
        }
    }

    function del() {
        var row = $("#emp-table").bootstrapTable('getSelections');
        var allCompID = "";
        if (row.length == 0) {
            $.modal.alertWarning("请选择需要离职的人员");
            return;
        }
        for (var i = 0; i < row.length; i++) {
            if (i == row.length - 1) {
                allCompID += row[i].compID
            } else {
                allCompID += row[i].compID + ","
            }
        }
        $.ajax({
            async: false,
            url: "/jpbi/comp/remove",
            data: {
                "allCompID": allCompID,
            },
            type: "post",
            dataType: "json",
            success: function (data) {
                $("#emp-table").bootstrapTable('refresh');
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                alert("错误,请联系管理员,错误信息:" + textStatus);
            }
        });

    }

    function detail() {
        var row = $("#emp-table").bootstrapTable('getSelections');
        var num = 0;
        var allEid = "";
        if (row.length == 0) {
            $.modal.alertWarning("请选择需要查看的人员");
            return;
        }
        for (var i = 0; i < row.length; i++) {
            $.operate.detail_currency(row[i].compID, row[i].title, "/jpbi/comp/detail","xiao");
        }
    }
</script>
</body>
</html>